<!-- include tpl=head -->
<script type="text/javascript" src="{func include_js list.js}"></script>
<script type="text/javascript">
function set_ext_cateid(val)
{
	var main_cateid = $("input[name=cate_id]:checked").val();
	if(!main_cateid || main_cateid == 'undefined'){
		$("input[name=cate_id][value="+val+"]").attr('checked',true);
		return true;
	}
	if(main_cateid == val){
		$("#ext_cate_id_"+val).attr('checked',true);
		$.dialog.alert('{lang当前分类已设置为主分类，扩展分类不支持取消}');
	}
}
function set_main_cateid(val)
{
	$("input[name=cate_id][value="+val+"]").attr('checked',true);
	$("#ext_cate_id_"+val).attr('checked',true);
}

$(document).keypress(function(e){
	if(e.ctrlKey && e.which == 13 || e.which == 10) {
		$('#phpok_submit_{$pid}').click();
	}
});
$(document).ready(function(){
	$("#_listedit").submit(function(){
		var id = $("#id").val();
		var pcate = parseInt("{$p_rs.cate}");
		var pcate_multiple = '{$p_rs.cate_multiple}';
		$(this).ajaxSubmit({
			'url':'{url ctrl=list func=ok /}',
			'type':'post',
			'dataType':'json',
			'success':function(rs){
				if(rs.status == 'ok'){
					var url = "{url ctrl=list func=action id=$pid/}";
					if(pcate>0){
						if(pcate_multiple > 0){
							var cateid = $("input[name=cate_id]:checked").val();
						}else{
							var cateid = $("#cate_id").val();
						}
						url += "&cateid="+cateid;
					}
					if(id){
						$.dialog.alert('{lang内容信息修改成功}',function(){
							$.phpok.go(url);
						},'succeed');
					}else{
						$.dialog({
							'icon':'succeed',
							'content':'{lang内容添加操作成功，请选择继续添加或返回列表}',
							'ok':function(){$.phpok.reload();},
							'okVal':'{lang继续添加}',
							'cancel':function(){$.phpok.go(url);},
							'cancelVal':'{lang返回列表}',
							'lock':true
						});
					}
				}else{
					$.dialog.alert(rs.content);
				}
			}
		});
		return false;
	});
});
</script>
<div class="tips">
	{lang您当前的位置：}{lang内容管理}
	<!-- if $pid -->
		<!-- loop from=$plist key=$key value=$value id=plist_id -->
		&raquo; <a href="{echo admin_url('list','action')}&id={$value.id}" title="{$value.title}">{$value.title}</a>
		<!-- /loop -->
	<!-- /if -->	
	<!-- if $parent_id -->
	&raquo; {lang父主题：}<a href="{echo admin_url('list','edit')}&id={$parent_id}" title=""><span class="red">{$parent_rs.title}</span></a>
	<!-- /if -->
	&raquo; <!-- if $id -->{lang编辑内容}<!-- else -->{lang添加内容}<!-- end -->
</div>
<form method="post" id="_listedit">
<input type="hidden" name="id" id="id" value="{$id}" />
<input type="hidden" name="pid" id="pid" value="{$pid}" />
<input type="hidden" name="parent_id" id="parent_id" value="{$parent_id}" />
<div class="main1">
	<div class="table">
	<div class="content">
		<input type="text" name="title" id="title" value="{$rs.title}" class="title" placeholder="请在此输入{$p_rs.alias_title ? $p_rs.alias_title : '主题'}{if $p_rs.alias_note}，{$p_rs.alias_note}{/if}" />
	</div>
	</div>
	<!-- if $attrlist && $p_rs.is_attr -->
	<div class="table"><div class="content">
	<ul class="layout">
		<li>{lang属性：}</li>
		<!-- php:$attr = $rs.attr ? explode(",",$rs.attr) : array() -->
		<!-- loop from=$attrlist key=$key value=$value -->
		<li><label><input type="checkbox" name="attr[]" id="_attr_{$key}" value="{$key}"{if in_array($key,$attr)} checked{/if} />{$value}</label></li>
		<!-- /loop -->
	</ul>
	</div></div>
	<!-- /if -->
	<!-- if $p_rs.cate && !$p_rs.cate_multiple -->
	<div class="table"><div class="content">
	<select name="cate_id" id="cate_id" style="width:99%;padding:3px;">
		<option value="">请选择分类…</option>
		<!-- loop from=$catelist key=$key value=$value id=$tmpid -->
		<option value="{$value.id}"{if $value.id == $rs.cate_id} selected{/if}>{$value._space}{$value.title}</option>
		<!-- /loop -->
	</select>
	</div></div>
	<!-- /if -->
	<!-- loop from=$extlist key=$key value=$value id=extlist_id -->
	<div class="table clearfix">
		<div class="title">
			{$value.title}：
			<span class="note">{$value.note}
				<!-- if $value.is_edit -->
				<!-- if $ext_module != 'add-list' -->
				<a class="icon edit" onclick="ext_edit('{$value.identifier}','{$ext_module}')"></a>
				<!-- /if -->
				<a class="icon delete" onclick="ext_delete('{$value.identifier}','{$ext_module}','{$value.title}')"></a>
				<!-- /if -->
			</span>
		</div>
		<div class="content">{$value.html}</div>
	</div>
	<!-- /loop -->
	<!-- if $p_rs.is_tag -->
	<div class="table">
		<div class="title">
			Tag标签
			<span class="note">多个Tag用英文空格分开，最多不能超过10个</span>
		</div>
		<div class="content"><input type="text" id="tag" name="tag" class='title' value='{$rs.tag}' /></div>
	</div>
	<!-- /if -->
</div>
<div class="main2">
	<!-- if $p_rs.is_identifier -->
	<div class="pfw mb10">
		<h3>{lang自定义网址标识}</h3>
		<div style="padding:5px">
			<div class="gray">{lang限}<span class="red">{lang字母、数字、下划线或中划线且必须是字母开头，}</span></div>
			<div style="padding:5px 0;"><input type="text" id="identifier" name="identifier" value="{$rs.identifier}" style="width:99%;margin-bottom:5px;" /></div>
		</div>
	</div>
	<!-- /if -->
	<!-- if $p_rs.cate && $p_rs.cate_multiple -->
	<div class="pfw mb10">
		<h3>所属分类</h3>
		<div class="cate_list clearfix" style="margin:0;max-height:250px;overflow-y:scroll;">
			<table width="100%" cellpadding="0" cellspacing="0">
			<tr>
				<th width="30px">主</th>
				<th>扩展分类</th>
			</tr>
			<!-- loop from=$catelist key=$key value=$value id=$tmpid -->
			<tr{if $tmpid.num%2} class="list"{/if}>
				<td align="center"><input type="radio" name="cate_id" value="{$value.id}"{if $rs.cate_id == $value.id} checked{/if} onclick="set_main_cateid('{$value.id}')" /></td>
				<td>
					<table cellpadding="0" cellspacing="0">
					<tr>
						<!-- for($i=1;$i<$value._layer;$i++) -->
						<td class="cate_line">&nbsp;</td>
						<!-- /for -->
						<!-- if $value._layer -->
						<td class="cate_middle">&nbsp;</td>
						<!-- /if -->
						<td><input type="checkbox" name="ext_cate_id[]" value="{$value.id}" id="ext_cate_id_{$value.id}" onclick="set_ext_cateid('{$value.id}')"{if in_array($value.id,$extcate)} checked{/if} /></td>
						<td><label for="ext_cate_id_{$value.id}">{$value.title}</label></td>
					</tr>
					</table>
				</td>
			</tr>
			<!-- /loop -->
			</table>
		</div>
	</div>
	<!-- /if -->
	<script type="text/javascript">
	function show_dateline()
	{
		laydate({
			elem:"#dateline",
			istime: true,
			format: 'YYYY-MM-DD hh:mm:ss',
			fixed:true
		});
	}
	</script>
	<div class="pfw mb10">
		<h3>{lang其他属性}</h3>
		<table width="100%">
		<tr>
			<td align="right">{lang状态：}</td>
			<td>
				<ul class="layout">
					<li><label><input type="radio" name="status" id="status_0" value="0"{if $id && !$rs[status]} checked{/if} />{lang未审核}</label></li>
					<li><label><input type="radio" name="status" id="status_1" value="1"{if !$id || $rs[status]} checked{/if} />{lang已审核}</label></li>
				</ul>
			</td>
		</tr>
		<tr>
			<td align="right">{lang是否隐藏：}</td>
			<td>
				<ul class="layout">
					<li><label><input type="radio" name="hidden" id="hidden_0" value="0"{if !$rs[hidden]} checked{/if} />{lang显示}</label></li>
					<li><label><input type="radio" name="hidden" id="hidden_1" value="1"{if $rs.hidden} checked{/if} />{lang隐藏}</label></li>
				</ul>
			</td>
		</tr>
		<tr>
			<td align="right">{lang发布时间：}</td>
			<td><input type="text" id="dateline" name="dateline" class="default" value="{if $rs.dateline}{func date 'Y-m-d H:i:s' $rs.dateline}{else}{func date 'Y-m-d H:i:s' $sys.time}{/if}" onfocus="show_dateline()" /></td>
		</tr>
		<tr>
			<td align="right">{lang阅读量：}</td>
			<td><input type="text" id="hits" name="hits" class="short" value="{$rs.hits}" /></td>
		</tr>
		<tr>
			<td align="right">{lang排序：}</td>
			<td><input type="text" id="sort" name="sort" class="short" value="{$rs.sort}" /></td>
		</tr>
		</table>
	</div>
	<!-- if $p_rs.is_tpl_content -->
	<div class="pfw mb10">
		<h3>{lang自定义内容模板}</h3>
		<table width="100%">
		<tr>
			<td><input type="text" id="tpl" name="tpl" class="default" value="{$rs.tpl}" /></td>
			<td><input type="button" value="选择" onclick="phpok_tpl_open('tpl')" class="btn" /></td>
			<td><input type="button" value="清空" onclick="$('#tpl').val('');" class="btn" /></td>
		</tr>
		<tr>
			<td colspan="3">
				<div class="gray">{lang为空将使用} <span class="red">{$p_rs.tpl_content ? $p_rs.tpl_content : $p_rs.identifier.'_content'}</span></div>
			</td>
		</tr>
		</table>
	</div>
	<!-- /if -->
	<!-- if $p_rs.is_seo -->
	<div class="pfw mb10">
		<h3>{langSEO优化}</h3>
		<div class="table">
			<div class="title">
				{langSEO标题：}
				<span class="note">{lang设置此标题后，网站Title将会替代默认定义的，不能超过50个汉字}</span>
			</div>
			<div class="content">
				<input type="text" id="seo_title" name="seo_title" class="long" value="{$rs.seo_title}" />
			</div>
		</div>
		<div class="table">
			<div class="title">
				{langSEO关键字：}
				<span class="note">{lang多个关键字用英文逗号隔开，为空将使用默认}</span>
			</div>
			<div class="content">
				<input type="text" id="seo_keywords" name="seo_keywords" class="long" value="{$rs.seo_keywords}" />
			</div>
		</div>
		<div class="table">
			<div class="title">
				{langSEO描述：}
				<span class="note">{lang简单描述该主题信息，用于搜索引挈，不支持HTML，不能超过85个汉字}</span>
			</div>
			<div class="content">
				<textarea name="seo_desc" id="seo_desc" class="long">{$rs.seo_desc}</textarea>
			</div>
		</div>
	</div>
	<!-- /if -->
	<div class="pfw mb10">
		<h3>{lang扩展主题字段}</h3>
		<div class="table">
			<div class="content">
				<select id="_tmp_select_add" style="padding:3px">
					<option value="">请选择扩展字段…</option>
					<!-- loop from=$extfields key=$key value=$value -->
					<option value="{$value.id}">{$value.title} - {$value.identifier}</option>
					<!-- /loop -->
				</select>
			</div>
			<div class="content">
				<div class="button-group">
					<input type="button" value="{lang快速添加}" onclick="_update_select_add()" class="phpok-btn" />
					<input type="button" value="{lang手动创建字段}" onclick="ext_add('{$ext_module}')" class="phpok-btn" />
				</div>
			</div>
		</div>
	</div>
	<script type="text/javascript">
	function _update_select_add()
	{
		var val = $("#_tmp_select_add").val();
		if(!val){
			$.dialog.alert('请选择要添加的扩展');
			return false;
		}
		ext_add2(val,'{$ext_module}');
	}
	</script>
</div>
<div class="clear"></div>
<div class="table">
	<div class="content">
		<input type="submit" value="{lang提 交}" class="submit2" id="phpok_submit_{$pid}" />
	</div>
</div>
</form>
<script type="text/javascript">
function win_resize()
{
	var width = $('.main .tips').width();
	if(width>=1000){
		var main1_width = width - 320;
		$(".main1").css('width',main1_width+"px").css('float','left');
		$(".main2").css('width','300px').css('float','right');
		var h = $(".main2").height();
		var d_h = $(window).height() - 30;
		if(h < d_h){
			$('.main2').css('position','fixed').css('top','30px').css('right','0px');
		}
	}else{
		$(".main1,.main2").css('width',width+"px").css("float",'none');
	}
}
$(document).ready(function(){
	win_resize();
	$(window).resize(win_resize);
});
</script>

<!-- inc:foot -->